<?php
	//Xay dung tim kiem
	//var_dump($this->User);
	
	$ssFilter 		= $this->arrParam['ssFilter'];
	$page = '';
	if(isset($this->arrParam['page'])){
		$page = '/page/' . $this->arrParam['page'];
	}
	$action_link 	= $this->baseUrl($this->currentController . '/filter/type/order');
	
	$lblName 		= $this->cmsLinkSort('Tên nhân viên','c.name_nhanvien',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblPhongban 	= $this->cmsLinkSort('Thuộc phòng ban','c.name_phongban',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblHdDongia 	= $this->cmsLinkSort('Đơn giá hợp đồng','c.hd_dongia',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblHdThanhtien = $this->cmsLinkSort('Thành tiền sau KM','c.hd_thanhtien',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblHdDadong 	= $this->cmsLinkSort('Số tiền đã thu','c.hd_sotiendadong',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblKhNo	 	= $this->cmsLinkSort('Khách hàng còn nợ','c.hd_sotienno',$ssFilter,$this->imgUrl . '/admin',$action_link);
	$lblNgayky	 	= $this->cmsLinkSort('Tháng','c.ngayky',$ssFilter,$this->imgUrl . '/admin',$action_link);
	

	$lblID 			= $this->cmsLinkSort('ID','c.id',$ssFilter,$this->imgUrl . '/admin',$action_link);

	$keywords = $this->formText('keywords',$ssFilter['keywords'],array('class'=>'txtshort txtsearch'));
	
	$optionsThang=array("0"=> '- Chọn tháng -',"01"=> 'Tháng 1',"02"=> 'Tháng 2',"03"=> 'Tháng 3',"04"=> 'Tháng 4',"05"=> 'Tháng 5',"06"=> 'Tháng 6',"07"=> 'Tháng 7',"08"=> 'Tháng 8',"09"=> 'Tháng 9',"10"=> 'Tháng 10',"11"=> 'Tháng 11',"12"=> 'Tháng 12');
	
	$date = new Zend_Date();
	$dateNamnay = $date->toString('YYYY');
	$dateNam = $dateNamnay;
	if(isset($ssFilter['date_nam'])) {
		$dateNam = $ssFilter['date_nam'];
	}

	
	for ($i = 0; $i <= 10; $i++){
		$optionsNam[$dateNamnay-$i] = $dateNamnay-$i;
	}

	$linkSlbNam			 	= $this->baseUrl($this->currentController . '/filter-info/type/date_nam/id/' . $this->arrParam['id']);
	$selectNam	 			= $this->formSelect('date_nam',$dateNam,array('onchange'=>"OnSubmitForm('" .$linkSlbNam ."')"), $optionsNam);
	
	//$strSearch = $keywords . ' ' . $btnSearch . ' ' . $btnResetSearch;
	
	$strSearchRight = $selectNam ;
	
	//$strSearchRight = $selectClb . ' ' . $selectStatus;
	//$strSearchRight = $selectLanguages;
	
	
?>

<div class="left_content">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/left.php');?>
	
</div>

<div class="right_content">
	<div class="appContent">
	<?php echo $this->render($this->arrParam['controller'] . '/toolbar/index.php');?>
		
	<form action="" method="post" name="appForm">
	 
	<div class="tblForm">
	
		
		<div class="formList goc5">
			<div class="appTop goct5">
				<div class="block_filter">
					<div class="fl">
						<div class="listSearch">
							<?php //echo $strSearch; ?>
							
							<table class="">
								<tr align="left">
									<td width="150"><a href=""><b>Thông tin nhân viên:</b></a></td>
									<td></td>
								</tr>
								<tr align="left">
									<td></td>
									<td></td>
								</tr>
								<tr align="left">
									<td width="150"><a href="">Họ tên nhân viên:</a></td>
									<td><a href=""><?php echo $this->User['name_nhanvien']; ?></a></td>
								</tr>
								<tr align="left">
									<td><a href="">User name:</a></td>
									<td><a href=""><?php echo $this->User['user_name']; ?></a></td>
								</tr>
								<tr align="left">
									<td><a href="">Email:</a></td>
									<td><a href=""><?php echo $this->User['email']; ?></a></td>
								</tr>
								<tr align="left">
									<td><a href="">Thuộc phòng ban:</a></td>
									<td><a href=""><?php echo $this->User['name_phongban']; ?></a></td>
								</tr>
							</table>
							<br/><br/>
							<div class="clr"></div>			
						</div>
					</div>
					<div class="fr listSelect">
						<?php echo $strSearchRight;?>
					</div>
					<div class="clr"></div>
				</div>
			</div>
			<div class="appBody">
				<table class="tblList">
					<tr>
						 
						<th><a href=""><?php echo $lblHdDongia;?></a></th>
						<th><a href=""><?php echo $lblHdThanhtien; ?></a></th>
						<th><a href=""><?php echo $lblHdDadong; ?></a></th>
						<th><a href=""><?php echo $lblKhNo; ?></a></th>
						<th><a href=""><?php echo $lblNgayky; ?></a></th> 
					</tr>
					
					<?php
					$date = new Zend_Date();
					$time= $date->get('dd-MM-YYYY');
				$hd_dongia =0;
				$hd_thanhtien =0;
				$hd_sotienno =0;
				$hd_sotiendadong =0;
// 				echo '<pre>';
// 				print_r($this->Items);
// 				echo '</pre>';
				
				for ($i = 1; $i <= 12; $i++){
					
					$id 				= $this->Items[$i]['id'];
 					$id_nhanvien 		= $this->Items[$i]['id_nhanvien'];
// 					$name 				= $val['name_nhanvien'];
// 					$NamePhongBan		= $val['name_phongban'];
// 					$NameKhachhang		= $val['name_khachhang'];
					$HdDongia			= $this->Items[$i]['hd_dongia'];
					$hd_dongia			=$hd_dongia + $this->Items[$i]['hd_dongia'];
					$HdThanhtien		= $this->Items[$i]['hd_thanhtien'];
					$hd_thanhtien		=$hd_thanhtien + $this->Items[$i]['hd_thanhtien'];
					$HdSotienno		 	= $this->Items[$i]['hd_sotienno'];
					$hd_sotienno		=$hd_sotienno + $this->Items[$i]['hd_sotienno'];
					$HdDadong		 	= $this->Items[$i]['hd_sotiendadong'];
					$hd_sotiendadong		=$hd_sotiendadong + $this->Items[$i]['hd_sotiendadong'];
					$user_name			= $this->Items[$i]['user_name'];
					$Ngayky 			= $this->Items[$i]['ngayky'];
						
					$linkInfo		= $this->baseUrl($this->currentController . '/info/id/' . $id . $page);
					$btnInfo		= $this->cmsIconButton('Xem thông tin', $this->imgUrl . '/admin/icon_info.png', $linkInfo);
					
					$linkEdit		= $this->baseUrl($this->currentController . '/edit/id/' . $id . $page);
					$btnEdit		= $this->cmsIconButton('Sửa', $this->imgUrl . '/admin/icon_edit.png', $linkEdit);
					
					$linkDelete		= $this->baseUrl($this->currentController . '/delete/id/' . $id . $page);
					$btnDelete		= $this->cmsIconButton('Xóa', $this->imgUrl . '/admin/publish_r.png', $linkDelete);
					
					$linkinfoDoanhthu 		= $this->baseUrl($this->currentController . '/info/id/' . $id_nhanvien);
					$linkinfoListHD		 	= $this->baseUrl($this->currentController . '/listhopdong/id/' . $id_nhanvien);
					$btnAdd			= $this->cmsIconButton('Tùy chọn', $this->imgUrl . '/menu/icon-16-maintenance.png', 'javascript::void(0)', array('onclick' => 'showFunction('. $id .')'));
					$divAdd			= 	'<div class="blockFunction selectFunction'.$id .'">
											<ul>
												<li><a href="'.$linkinfoListHD.'">Xem danh sách HĐ</a></li>
												<li><a href="'.$linkinfoDoanhthu.'">Xem doanh thu NV</a></li>
											</ul>
										</div>';
					
					//$strIconButton 	= $btnInfo . ' ' . $btnDelete;
					$strIconButton 	=  $btnAdd.''.$divAdd;
					$hoten 	= '<b><a href="' . $linkInfo . '">' . $hoten . '</a></b>';
					
					$classRow = 'row1';
					if(($i - 1) % 2 == 0)
					$classRow = 'row0';
						
			?>
			<tr class="<?php echo $classRow;?>">
				<td align="left"><a href=""><span class="auto_numberic "><?php if($HdDongia==null){$HdDongia=0;} echo $HdDongia;?></span></a></td>
				<td align="left"><a href=""><span class="auto_numberic "><?php  if($HdThanhtien==null){$HdThanhtien=0;}  echo $HdThanhtien;?></span></a></td>
				<td align="left"><a href=""><span class="auto_numberic "><?php  if($HdDadong==null){$HdDadong=0;}  echo $HdDadong;?></span></a></td>
				<td align="left"><a href=""><span class="auto_numberic red"><?php  if($HdSotienno==null){$HdSotienno=0;}  echo $HdSotienno;?></span></a></td>
				<td align="left"><a href=""><span class="auto_numberic red">Tháng <?php echo $i;?></span></a></td>
			</tr>
			<?php
				} 
			?> 
			<tr style="background-color: #e8f6fe;">
				<td align="left"><a><span class="auto_numberic" style="font-weight: bold;">Tổng :<?php echo $hd_dongia;?></span></a></td>
				<td align="left"><a><span class="auto_numberic" style="font-weight: bold;">Tổng :<?php echo $hd_thanhtien;?></span></a></td>
				<td align="left"><a><span class="auto_numberic" style="font-weight: bold;">Tổng :<?php echo $hd_sotiendadong;?></span></a></td>
				<td align="left"><a><span class="auto_numberic" style="font-weight: bold;">Tổng :<?php echo $hd_sotienno;?></span></a></td>
				<td align="left"></td>
			</tr>
			</table>
			</div>
			<div class="appBottom">
				<div class="pagination">
							<?php
								//$currentUrl = $this->baseUrl($this->currentController . '/index');
								//echo $this->paginationControl($this->paginator,'Sliding','pagination.phtml',array('currentUrl'=>$currentUrl)); 
							?>
				</div>
			</div>
		</div>
	</div> 
	</form>
	</div>
</div>
<div class="clr"></div>	
<script type="text/javascript">
	function showFunction(i){
		$('.selectFunction' + i).show();
		$('body').append('<div id="overlay" style="width:100%; height:100%; top: 0; left: 0; z-index: 499; position: fixed;" onclick="hideOption()"></div>');
	}
	function hideOption(){
		$('.blockFunction').hide();
		$('#overlay').remove();
	}
</script>
